Field of the Disclosure
The present disclosure relates generally to processors and more particularly to atomic operations for processors.
Description of the Related Art
Processors often employ multiple processing units, such as a central processing unit (CPU) and graphics processing unit (GPU), wherein each processing unit can include multiple cores or other processing modules. The multiple processing units enhance processing efficiency both by providing dedicated hardware for different types of operations (e.g., graphics and display operations executed at the GPU and general computation operations and system management operations executed at the CPU) and by supporting parallel processing of operations. For example, an operating system or other module can divide one or more executing programs into subsets of instructions, referred to as threads, and assign each thread to a different processing unit for execution. At least some of the threads can be executed concurrently (in parallel), thereby increasing the speed with which the one or more programs are executed.
In the course of their concurrent execution, multiple threads may need to access the same memory location at a memory associated with the processor. To prevent race conditions and other errors, the processor can support atomic memory operations, wherein each atomic memory operation, when executed by a thread, appears to other threads as occurring instantaneously or is otherwise not interruptible by other threads. The atomic memory operations can be used in mutual exclusion schemes and other shared memory management schemes to ensure that a memory location is not simultaneously accessed by multiple threads. One class of atomic memory operations is generally referred to as the “fetch-and-phi” class, wherein a fetch-and-phi memory operation atomically fetches and modifies the contents of a memory location. Fetch-and-phi operations are useful in a variety of shared memory management schemes. However, fetch-and-phi operations cannot be executed conditionally, that is, executed or not based on the contents of the memory location being fetched. This lack of conditionality limits the usefulness of fetch-and-phi operations.